package com.zjz.springcloud.controller;

import com.zjz.springcloud.pojo.Dept;
import com.zjz.springcloud.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/10/05/6:37
 * @Description:本身没有实体类,但是pom引入了,本身没有服务service,没有dao,怎么拿到数据
 * @Target:从其它地方拿到数据,间接的通过RestTemplate
 */

@RestController
public class DeptConsumerController {

    @Autowired
    private RestTemplate restTemplate;  // 提供多种便捷访问远程http服务的方法,简单的RestFul服务模板

    @Autowired
    private DeptClientService service;


    @RequestMapping("/consumer/dept/add")
    public boolean add(Dept dept){
        return this.service.addDept(dept);
    }

    @RequestMapping("/consumer/dept/get/{deptno}")
    public Dept get(@PathVariable("deptno")Long deptno){
        return  this.service.queryById(deptno);

    }

    @RequestMapping("/consumer/dept/list")
    public List<Dept> list(){
        return this.service.queryAll();
    }












}
